package com.ziqing.apeletnews.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.ziqing.apeletnews.R;
import com.ziqing.apeletnews.adapter.ProduceAdapter;
import com.ziqing.apeletnews.base.BaseFragment;
import com.ziqing.apeletnews.bean.ListBean;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by WT on 2018/4/12.
 */

public class RecentlyFragment extends BaseFragment {


    @BindView(R.id.rv_recently)
    RecyclerView rvRecently;

    Unbinder unbinder;
    private ProduceAdapter adapter;
    private List<ListBean> data = new ArrayList<>();

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_recently, container, false);
        unbinder = ButterKnife.bind(this, view);
        initView();
        rvRecently.setNestedScrollingEnabled(false);
        return view;
    }

    public void initView() {

        data.add(new ListBean("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1523540008011&di=787efacfa7c9ffe22f055cf798f4adca&imgtype=0&src=http%3A%2F%2Fcrawl.nosdn.127.net%2F8d6ffc6437b8e1e61db526f65c84c210.jpg","10个用Java谋生非常有趣的方式"));
        data.add(new ListBean("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1523540008011&di=787efacfa7c9ffe22f055cf798f4adca&imgtype=0&src=http%3A%2F%2Fcrawl.nosdn.127.net%2F8d6ffc6437b8e1e61db526f65c84c210.jpg","10个用Java谋生非常有趣的方式"));
        data.add(new ListBean("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1523540008011&di=787efacfa7c9ffe22f055cf798f4adca&imgtype=0&src=http%3A%2F%2Fcrawl.nosdn.127.net%2F8d6ffc6437b8e1e61db526f65c84c210.jpg","10个用Java谋生非常有趣的方式"));
        data.add(new ListBean("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1523540008011&di=787efacfa7c9ffe22f055cf798f4adca&imgtype=0&src=http%3A%2F%2Fcrawl.nosdn.127.net%2F8d6ffc6437b8e1e61db526f65c84c210.jpg","10个用Java谋生非常有趣的方式"));
        data.add(new ListBean("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1523540008011&di=787efacfa7c9ffe22f055cf798f4adca&imgtype=0&src=http%3A%2F%2Fcrawl.nosdn.127.net%2F8d6ffc6437b8e1e61db526f65c84c210.jpg","10个用Java谋生非常有趣的方式"));
        data.add(new ListBean("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1523540008011&di=787efacfa7c9ffe22f055cf798f4adca&imgtype=0&src=http%3A%2F%2Fcrawl.nosdn.127.net%2F8d6ffc6437b8e1e61db526f65c84c210.jpg","10个用Java谋生非常有趣的方式"));

        rvRecently.setLayoutManager(new GridLayoutManager(getActivity(),2, GridLayoutManager.VERTICAL,false));
        adapter = new ProduceAdapter(getActivity(),data,R.layout.item_recycle_recent);

        rvRecently.setAdapter(adapter);
        adapter.notifyDataSetChanged();
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
